<?php

if ($data['info']['type'] == 'video') { // 视频
    // 输出页面
    commonHtml('<div class="weui-msg__text-area">
            <h2 class="weui-msg__title">视频解析成功</h2>
            <p class="weui-msg__desc" style="margin-bottom: 25px;">@' . $data['owner']['username'] . '的 Instagram 视频</p>
            <img src="' . $data['info']['thumb'] . '" style="width: 100%" />
        </div><p class="weui-btn-area">
        <a href="' . url('download') . 'download?data=' . urlencode(json_encode($data)) . '" class="weui-btn weui-btn_primary">点击下载</a>
        </p>', '@' . $data['owner']['username'] . '的 Instagram 视频 | Instagram', true);
} else if ($data['info']['type'] == 'images') { // 多图
    $images = '';
    foreach ($data['info']['images'] as $v) {
        $images .= '<div class="swiper-slide"><img src="' . $v['thumb'] . '" style="width: 100%" /></div>';
    }
    // 输出页面
    commonHtml('<link rel="stylesheet" href="https://unpkg.com/swiper/css/swiper.min.css">
        <script src="https://unpkg.com/swiper/js/swiper.min.js"></script>
        <div class="weui-msg__text-area">
            <h2 class="weui-msg__title">长按保存图片</h2>
            <p class="weui-msg__desc" style="margin-bottom: 25px;">@' . $data['owner']['username'] . '的 Instagram 所有照片</p>
            <div class="swiper-container">
                <div class="swiper-wrapper">' . $images . '</div>
                <div class="swiper-pagination"></div>
            </div>
            <script>        
            var mySwiper = new Swiper (".swiper-container", {
                loop: true, // 循环模式选项
                pagination: { // 分页器
                    el: ".swiper-pagination",
                },
            })        
            </script>
        </div>', '@' . $data['owner']['username'] . '的 Instagram 所有照片 | Instagram');
} else { // 默认单图
    // 输出页面
    commonHtml('<div class="weui-msg__text-area">
            <h2 class="weui-msg__title">长按保存图片</h2>
            <p class="weui-msg__desc" style="margin-bottom: 25px;">@' . $data['owner']['username'] . '的 Instagram 照片</p>
            <img src="' . $data['info']['thumb'] . '" style="width: 100%" />
        </div>', '@' . $data['owner']['username'] . '的 Instagram 照片 | Instagram');
}
